<?php

function search($array, $key, $value)
{
    $results = array();

    if (is_array($array))
    {
        if (isset($array[$key]) && $array[$key] == $value)
            $results[] = $array;

        foreach ($array as $subarray)
            $results = array_merge($results, search($subarray, $key, $value));
    }
    return $results;
}

function search_between($array, $key, $value, $max_value)
{
    $results = array();
    if($max_value == "*") $max_value = 9999999999;
    
    if (is_array($array))
    {
        if (isset($array[$key]) && $array[$key] >= $value && $array[$key] <= $max_value)
            $results[] = $array;

        foreach ($array as $subarray)
            $results = array_merge($results, search_between($subarray, $key, $value, $max_value));
    }
    return $results;
}
?>
